<script>
$(document).ready(function(){
	
	var c = {
		submitok:function(o1){
			var da = js.getformdata('formcog');
			
			js.ajax.post({
				url:'api/plat/cogsave',
				data:da,
				btnobj:o1
			},function(){
				o1.disabled=false;
			});
			systemtitle = da.systemtitle;
			js.setoption('systemtitle',systemtitle);
			$('#hometitle').html(systemtitle);
			xcy.setTitle(systemtitle);
			var info = {url:da.rockfile_url,key:da.rockfile_key};
			js.setoption('rockfile',info);
		},
		init:function(){
			jsform('systemtitle','formcog').value=systemtitle;
			var infostr = js.getoption('rockfile');
			if(infostr){
				var info 	= js.decode(infostr);
				jsform('rockfile_url','formcog').value=info.url;
				jsform('rockfile_key','formcog').value=info.key;
			}
			js.ajax.get({
				url:'api/plat/coginfo'
			},function(ret){
				c.showdata(ret.data);
			});
			importjs('tab');
			$(this.formobj('smstype')).change(function(){
				c.changesmstype(this);
			});
		},
		showdata:function(da){
			for(var i in da)this.formobj(i).value=da[i];
		},
		formobj:function(fid){
			return jsform(fid,'formcog');
		},
		clicktab:function(o,lx){
			js.tab.click(o,lx, function(tid){
				if(tid=='3')c.changesmstype(c.formobj('smstype'));
			});
		},
		changesmstype:function(o){
			var val = o.value;
			$('#yunpian_div').hide();
			if(val=='yunpian'){
				$('#yunpian_div').show();
			}else{
				this.formobj('yunpiankey').value='';
			}
		},
		kscog:function(){
			js.modal.input({
				title:'快速设置',
				msg:'请输入服务器IP',
				type:'text'
			},function(jg,txt){
				if(jg=='yes' && txt)c.kscogs(txt);
			});
		},
		kscogs:function(txt){
			this.formobj('service_url').value='ws://'+txt+':6552/';
			this.formobj('service_push').value='http://127.0.0.1:6553/';
			this.formobj('service_recid').value='xinhujava';
			this.formobj('service_cehui').value='2';
		},
		testurl:function(){
			var dz = this.formobj('service_url').value;
			if(!dz)return;
			if(NOWURL.indexOf('https')==0 && dz.indexOf('wss')!=0){
				js.msg('msg','使用https必须配置wss才能通信');return;
			}
			js.modal.confirm('打开后显示“Upgrade Required”说明成功，其他都是失败。',function(jg){
				if(jg=='yes'){
					js.open('http'+dz.substr(2)+'',600,300);
				}
			});
		}
	}
	js.initbtn(c);
});
</script>

<div align="center">

	<table style="margin-top:50px"><tr valign="top">
	<td>
		<div class="rock-tabh">
			<div tabid="0" clickevt="clicktab,item" class="rock-tab-item active">平台信息</div>
			<div tabid="1" clickevt="clicktab,item" class="rock-tab-item">上传文件中心</div>
			<div tabid="2" clickevt="clicktab,item" class="rock-tab-item">通信服务端</div>
			<div tabid="3" clickevt="clicktab,item" class="rock-tab-item">短信设置</div>
		</div>
	</td>
	
	<td>
		<form name="formcog" autocomplete="off">
		<div style="padding:20px 30px;margin:0px 20px;min-width:300px" class="rock-panel rock-border rock-radius" align="left">
		
			<div tab="item0" >
				
				<div class="hui">平台名称：</div>
				<div style="display:flex"><input class="input" name="systemtitle" style="flex:1"></div>
				
				<div class="blank20"></div>
				<div class="hui">信呼官网key<a target="_blank" href="http://www.rockoa.com/view_xhkey.html">(帮助)</a>：</div>
				<div style="display:flex"><input class="input" name="xinhukey" style="flex:1"></div>
				
				<div class="blank20"></div>
				<div class="hui">找回密码手机验证码：</div>
				<div style="display:flex"><select class="input" name="findcode" style="flex:1">
				<option value="">不需要验证码</option>
				<option value="1">需要验证码</option>
				</select></div>
	
			</div>
			
			<div tab="item1" style="display:none">
				<div class="hui fontsize12" align="center">没设置这个，无法上传文件<a target="_blank" href="http://www.rockoa.com/view_rockfile.html" class="fontsize12">(帮助)</a></div>
				<div class="blank20"></div>
				<div class="hui">文件上传中心地址：</div>
				<div style="display:flex"><input class="input" name="rockfile_url" placeholder="不设置无法上传文件" style="flex:1"></div>
				<div class="blank20"></div>
				
				<div class="hui">文件上传中心应用Key：</div>
				<div style="display:flex"><input class="input" name="rockfile_key" style="flex:1"></div>

				
			</div>
			
			<div tab="item2" style="display:none">
				<div class="hui fontsize12" align="center">即时通信使用，以下可不用设置</div>
				<div class="blank20"></div>
				<div class="hui">通信地址：</div>
				<div style="display:flex"><input class="input" name="service_url" placeholder="ws开头(可不设置)" style="flex:1"></div>
				
				<div class="blank20"></div>
				<div class="hui">推送地址：</div>
				<div style="display:flex"><input class="input" placeholder="可不设置" name="service_push" style="flex:1"></div>
				
				<div class="blank20"></div>
				<div class="hui">recID号：</div>
				<div style="display:flex"><input class="input" placeholder="可不设置" name="service_recid" style="flex:1"></div>
				
				<div class="blank20"></div>
				<div class="hui">撤回时间(分钟)：</div>
				<div style="display:flex"><input class="input" type="number" onblur="js.number(this)" onfocus="js.focusval=this.value" min="0" name="service_cehui" placeholder="0不能撤回	" style="flex:1"></div>
				<div class="blank20"></div>
				<div align="center">
				<button clickevt="kscog" type="button" class="webbtn webbtn-mini webbtn-default">快速设置</button>
				<button clickevt="testurl" type="button" class="webbtn webbtn-mini webbtn-default">测试通信地址</button>
				</div>
				
			</div>
			

			
			<div tab="item3" style="display:none">
				
				<div class="hui">短信平台：</div>
				<div style="display:flex"><select class="input" name="smstype" style="flex:1">
				<option value="">信呼服务</option>
				<option value="yunpian">云片网</option>
				<option value="aliyun">阿里云(未开发)</option>
				</select></div>
				
				<div class="blank20"></div>
				
				<div class="hui">短信签名：</div>
				<div style="display:flex"><input class="input" name="smsqianm" style="flex:1"></div>
				
				<div id="yunpian_div" style="display:none">
				<div class="blank20"></div>
				<div class="hui">云片网key：</div>
				<div style="display:flex"><input class="input" name="yunpiankey" style="flex:1"></div>
				</div>
			
			</div>
			
		</div>
		
		</form>
		
		<div style="margin-top:30px" align="center"><button clickevt="submitok" style="width:150px" type="button" class="webbtn webbtn-big">保存</button></div>
	</td>
	
	</tr></table>

	
	
</div>